#include <cstdio>

#define MAX_LINE 6

typedef unsigned int uint;


inline uint binary_ones (uint n)
{
	static const uint s = sizeof (n) * 8;
	uint r, b;

	r = 0;
	b = 1;
	for (uint i = 0; i < s; ++i, b <<= 1)
		r += ((n & b) != 0);

	return r;
}


int main ()
{
	char line[MAX_LINE];
	uint test_cases, n;

	scanf ("%u\n", &test_cases);
	while (test_cases--)
	{
		fgets (line, MAX_LINE, stdin);
		sscanf (line, "%u", &n);
		printf("%u ", binary_ones (n));
		sscanf (line, "%x", &n);
		printf("%u\n", binary_ones (n));
	}

	return 0;
}